Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-853] Generate order replacement protos #1551

Merged
merged 5 commits into from
May 20, 2024

Conversation

chenyaoy
Copy link
Contributor

@chenyaoy chenyaoy commented May 20, 2024

Changelist

[Describe or list the changes made in this PR]

Test Plan

[Describe how this PR was tested (if applicable)]

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features

    • Introduced StatefulOrderEventV1 with enhanced functionalities.
    • Added OrderReplaceV1 with new encoding and decoding capabilities.
  • Improvements

    • Renamed several order placement status identifiers for better clarity and consistency.
    • Enhanced OrderPlaceV1 and OrderReplaceV1 with updated status types for improved order management.

Copy link

linear bot commented May 20, 2024

Copy link
Contributor

coderabbitai bot commented May 20, 2024

Walkthrough

The recent updates enhance the dydxprotocol indexer with new interfaces and messages for managing stateful order events and off-chain updates. These changes include the introduction of StatefulOrderEventV1 and OrderReplaceV1 structures, along with associated types and encoding/decoding functions. Moreover, certain types and functions have been renamed to enhance clarity and consistency in the codebase.

Changes

Files Change Summary
.../indexer/events/events.ts Added StatefulOrderEventV1 and related interfaces with alterations.
.../indexer/off_chain_updates/off_chain_updates.ts Renamed OrderPlaceV1_OrderPlacementStatus to OrderPlacementStatus and related functions. Added OrderPlaceV1, OrderPlaceV1SDKType, OrderReplaceV1, and OrderReplaceV1SDKType interfaces. Added encoding/decoding functions for OrderReplaceV1.
proto/dydxprotocol/indexer/events/events.proto Added StatefulOrderEventV1 message with alterations.
proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto Added OrderPlacementStatus enum and new constant. Added OrderReplaceV1 message with fields and alterations.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 9cb8bba and f7f9044.
Files ignored due to path filters (2)
  • protocol/indexer/events/events.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • protocol/indexer/off_chain_updates/types/off_chain_updates.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
Files selected for processing (4)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts (8 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/off_chain_updates/off_chain_updates.ts (12 hunks)
  • proto/dydxprotocol/indexer/events/events.proto (2 hunks)
  • proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto (2 hunks)
Additional Context Used
Path-based Instructions (4)
proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/off_chain_updates/off_chain_updates.ts (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

proto/dydxprotocol/indexer/events/events.proto (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

Additional comments not posted (9)
proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto (3)

24-44: The new OrderPlacementStatus enum is well-documented and covers various scenarios of order placement. Ensure that all systems using this enum are updated to handle the new values correctly.


102-108: The update to the OffChainUpdateV1 message to include OrderReplaceV1 is crucial for supporting new order replacement features. Confirm that the Kafka consumers are updated to parse this new field.


91-97: The addition of the OrderReplaceV1 message integrates well with the existing structure. It's important to verify that all components that interact with order messages can handle this new type.

indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/off_chain_updates/off_chain_updates.ts (3)

Line range hint 11-42: The TypeScript enum OrderPlacementStatus and its SDK counterpart are updated to reflect the new order placement statuses. Ensure that all TypeScript code handling these enums is updated accordingly.


Line range hint 281-311: The addition of OrderReplaceV1 and its SDK type in the TypeScript definitions is well done. This will facilitate the handling of order replacements in the TypeScript part of the system.


68-99: The functions orderPlacementStatusFromJSON and orderPlacementStatusToJSON are updated to handle the new enum values. It's important to ensure that all parts of the system that serialize or deserialize these values are aware of these changes.

proto/dydxprotocol/indexer/events/events.proto (1)

Line range hint 250-285: The addition of StatefulOrderReplacementV1 to the StatefulOrderEventV1 message is a significant update. It's crucial to ensure that all systems processing these events can handle the new order_replace field correctly.

indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts (2)

627-627: The addition of orderReplace fields in both StatefulOrderEventV1 and StatefulOrderEventV1SDKType interfaces aligns with the PR's objective to handle order replacements. Ensure that the corresponding logic to handle these new fields is implemented wherever these events are processed.

Also applies to: 642-642


716-718: Introduction of StatefulOrderEventV1_StatefulOrderReplacementV1 and StatefulOrderEventV1_StatefulOrderReplacementV1SDKType interfaces. This is a crucial addition for supporting the new order replacement functionality. It's important to ensure that the order field within these interfaces is properly utilized in the order processing logic to maintain the integrity of order replacements.

Also applies to: 721-723

@chenyaoy chenyaoy requested review from jayy04 and dydxwill May 20, 2024 16:50
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between f7f9044 and aab5fa3.
Files ignored due to path filters (2)
  • protocol/indexer/events/events.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • protocol/indexer/off_chain_updates/types/off_chain_updates.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
Files selected for processing (4)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts (8 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/off_chain_updates/off_chain_updates.ts (7 hunks)
  • proto/dydxprotocol/indexer/events/events.proto (2 hunks)
  • proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts
  • proto/dydxprotocol/indexer/events/events.proto
  • proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto
Additional Context Used
Path-based Instructions (1)
indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/off_chain_updates/off_chain_updates.ts (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

Additional comments not posted (4)
indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/off_chain_updates/off_chain_updates.ts (4)

283-294: The newly added interfaces OrderReplaceV1 and OrderReplaceV1SDKType are consistent with the existing pattern of interface definitions in the file.


Line range hint 601-631: The integration of OrderReplaceV1 into the OffChainUpdateV1 encoding and decoding functions is done correctly. This ensures that the new order replacement functionality is properly serialized and deserialized in the system's messaging framework.


513-575: The encoding and decoding functions for OrderReplaceV1 are implemented correctly following the established patterns in this file. It's important to ensure that the order field, which is optional, is handled correctly in all scenarios where OrderReplaceV1 is used.

Verification successful

The search results indicate that OrderReplaceV1 is used in various places within the off_chain_updates.ts file. The encoding, decoding, and fromPartial functions handle the optional order field correctly by checking if it is undefined before processing it.

  • Encoding: The encode function checks if message.order is undefined before encoding it.
  • Decoding: The decode function assigns message.order only if the corresponding tag is present.
  • fromPartial: The fromPartial function checks if object.order is undefined before assigning it to message.order.

These implementations ensure that the optional order field is handled correctly in all scenarios where OrderReplaceV1 is used.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct handling of the optional `order` field in `OrderReplaceV1`.

# Test: Search for usage of `OrderReplaceV1`. Expect: Correct handling of the optional `order` field.
rg --type typescript $'OrderReplaceV1'

Length of output: 72



Script:

#!/bin/bash
# Description: Verify correct handling of the optional `order` field in `OrderReplaceV1`.

# Test: Search for usage of `OrderReplaceV1`. Expect: Correct handling of the optional `order` field.
rg --type ts 'OrderReplaceV1'

Length of output: 2304


304-304: The addition of orderReplace to OffChainUpdateV1 and OffChainUpdateV1SDKType integrates the new order replacement functionality into the existing message structure sent to the Indexer. Ensure that all systems consuming these messages are updated to handle the new orderReplace field.

Also applies to: 315-315

@chenyaoy chenyaoy merged commit 722ec24 into main May 20, 2024
33 checks passed
@chenyaoy chenyaoy deleted the chenyao/order-replacement-protos branch May 20, 2024 18:50
@chenyaoy
Copy link
Contributor Author

@Mergifyio backport release/indexer/v5.x

Copy link
Contributor

mergify bot commented Jun 20, 2024

backport release/indexer/v5.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jun 20, 2024
* Generate order replacement protos

(cherry picked from commit 722ec24)

# Conflicts:
#	protocol/indexer/events/events.pb.go
#	protocol/indexer/off_chain_updates/types/off_chain_updates.pb.go
chenyaoy added a commit that referenced this pull request Jun 20, 2024
* Generate order replacement protos
chenyaoy added a commit that referenced this pull request Jun 20, 2024
* Generate order replacement protos
@chenyaoy chenyaoy mentioned this pull request Jun 21, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants